import axios from 'axios';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css'
import { BASE_URL } from '../config';
const myAxios = axios.create({
    baseURL: BASE_URL,
    timeout: 5000
})

myAxios.interceptors.request.use(function (config) {
    NProgress.start();
    return config;
}, function (error) {
    NProgress.done();
    return Promise.reject(error);
});


myAxios.interceptors.response.use(function (response) {
    NProgress.done();
    return response;
}, function (error) {
    NProgress.done();
    return Promise.reject(error);
});

export const $get = (url,params)=>{
    return myAxios.get(url,{params})
}
export const $post = (url,params)=>{
    return myAxios.post(url,params)
}